<html>
<head><meta charset="utf-8"><title>C Test programs in a Cargo project. · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/C.20Test.20programs.20in.20a.20Cargo.20project.2E.html">C Test programs in a Cargo project.</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236196637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/C%20Test%20programs%20in%20a%20Cargo%20project./near/236196637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/C.20Test.20programs.20in.20a.20Cargo.20project.2E.html#236196637">(Apr 26 2021 at 15:36)</a>:</h4>
<p>Hi,</p>
<p>Does anyone know a good way to build tests written in C (that link the Rust code that I'd like to test) from within a Cargo project.</p>
<p>I can't use the CC crate, as that can only build C code to static or dynamic libraries for inclusion into Rust code. I need the other way around.</p>
<p>I could probably cobble something together with <code>xtask</code>, <code>cargo make</code>,  or even just a scrip. But if there's already a solution that deals with everything (e.g. putting the build outputs into the <code>target</code> dir so they are automatically cleaned), then I'd rather use that.</p>
<p>[I'm actually only having to do this to work around <a href="https://github.com/rust-lang/rust/issues/84395">this bug</a>]</p>
<p>Thanks!</p>



<a name="236760812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/C%20Test%20programs%20in%20a%20Cargo%20project./near/236760812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ratijas <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/C.20Test.20programs.20in.20a.20Cargo.20project.2E.html#236760812">(Apr 29 2021 at 23:05)</a>:</h4>
<p>hi, you better take a look at CMake testing infrastructure. Cargo is not a general purpose task manager anyway. They can be used together with a help of Corrosion package.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>